package agentes;

import java.awt.Color;
import java.util.LinkedList;
import java.util.Random;

import libraries.PolygonLibraryManipulator;

import alice.tuprolog.Prolog;
import test.Coordinate;
import test.Polygon;

public class Spotty extends Thread{

	PolygonLibraryManipulator engine = new PolygonLibraryManipulator();
	LinkedList<Coordinate> vortexList;
	int c = 0;

	public Spotty(PolygonLibraryManipulator engine) throws Exception {
		this.engine = engine;
		vortexList = new LinkedList<Coordinate>();
	}

	@Override
	public void run() {
		Random rand = new Random();
		while (true) {
			vortexList.clear();
			int x, y;
			x = rand.nextInt(500);
			y = rand.nextInt(500);
//			System.out.println(x + "+" + y);
			vortexList.add(new Coordinate(x, y));
			vortexList.add(new Coordinate(x + 20, y - 10));
			vortexList.add(new Coordinate(x, y - 20));
			vortexList.add(new Coordinate(x - 20, y - 10));

			try {
				engine.drawPolygon(this.getClass().getSimpleName().toLowerCase(),new Polygon(("spotty" + c++), vortexList,
						new Color(100, 100, 100)));
				Thread.sleep(5000);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}

	}

}
